<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;


/**
 * 会员余额模型
 */
class UserAccountLog extends ModelBase
{

    protected $insert = ['create_time','serial_number'];

    /**
     * 连用户表
     */
    public function member(){
        return $this->belongsTo('Member','user_id','id');
    }

    /**
     * 连用户表
     */
    public function wallet(){
        return $this->belongsTo('Wallet','wallet_id','id');
    }

    /**
     * 连投资表
     */
    public function investment(){
        return $this->belongsTo('GamblerKingInvestment','investment_id','id');
    }
    /**
     * 获取类型信息
     */
    public function getTypeTextAttr(){
         $arr=['','后台充值','线下充值','转让','每日流水贡献奖励','线下提现','购买心血公式','购买赌王投资','撤资','分红','分享奖','平级奖','团队奖','洗码奖','购买会员卡','转出娱乐城','转换','亏损补平','游戏下注','游戏转入','划转','区块链充值','提币','发布OTC','OTC交易','总包充值游戏金豆','服务费','撤资手续费','惩罚金','下注','奖金','下注撤单','预测下注返点'];
        return $arr[$this->data['type']];
    }

    /**
     * 流水号自动完成
     */
    public function setSerialNumberAttr()
    {

        return date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
    }

    /**
     * logo
     */
    public function getNumberAttr($value)
    {
        if(in_array($this->wallet_id,[1,2,3])){
            return  sprintf("%.2f",$value);
        }else{
            return $value;
        }
    }




    /**
     * logo
     */
    public function getBeforeBlanceAttr($value)
    {
        if(in_array($this->wallet_id,[1,2,3])){
            return  sprintf("%.2f",$value);
        }else{
            return $value;
        }
    }


    /**
     * logo
     */
    public function getAfterBlanceAttr($value)
    {
        if(in_array($this->wallet_id,[1,2,3])){
            return  sprintf("%.2f",$value);
        }else{
            return $value;
        }
    }


    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr($value)
    {

        return TIME_NOW;
    }

    /**
     * 时间自动完成
     */
    public function getCreateTimeAttr($value)
    {

        return date('Y-m-d H:i:s',$value);
    }

//    public function  getRemarkAttr($value){
//
//        $lang=isset($_REQUEST['lang'])?$_REQUEST['lang']:'';
//        return   baidu_translate($value,$lang);
//
//
//    }


}
